﻿using System;
using System.Collections.Generic;
using System.Text;
using System.Data;

namespace DBManager.Admin
{
    public class ThuVienImages
    {
        public static DataTable GetAllImages(string nameImage)
        {
            string dk = "";
            if (nameImage != "")
            {
                dk = " and name like N'%" + nameImage + "%' ";
            }
            string sql = "select * from Images where 1=1 " + dk + " order by imageid desc";
            return DBUtil.SelectTable(sql);
        }
        public static string AddImages(string name, string img, string ShortContent)
        {
            string kq = "0";
            string sql = @"INSERT INTO Images(Name,img,ShortContent)
                           VALUES 
                           (" + comm.to_sqltext(name) + @"
                           ," + comm.to_sqltext(img) + @"
                           ," + comm.to_sqltext(ShortContent) + @")";
            try
            {
                DBUtil.Execute(sql);
                kq = "1";
            }
            catch (Exception)
            {
                kq = "0";
            }
            return kq;
        }
    }
}
